if (!jsx3.lang.Class.forName("ux.cdb.admin.system.department.departmentWizard.DepartmentInfoPane")) {
  jsx3.lang.Class.defineClass("ux.cdb.admin.system.department.departmentWizard.DepartmentInfoPane", 
  ux.megatron.gui.WizardPanel, 
  null, 
  function(block){
    /**
     * instance initializer
     * @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
     * @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
     */
    block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML){
      //call constructor for super class (the super expects the name of the object and the function that it is an instance of)
      this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
    };
    block.prototype.setData = function(record){
        var cdfDoc = jsx3.xml.CDF.Document.newDocument();
        cdfDoc.insertRecord(record);
        var me = this;
        setTimeout(function(){
            me.getDescendantOfName("blk_departmentInfoProvider").setData(cdfDoc);
        }, 0);
        this.mode = "edit";
        this.jsxid = record["jsxid"];
    };
    block.prototype.getMatrix = function() {
        return this.getAncestorOfType("ux.cdb.admin.system.department.Department").getMatrix();
    };
    block.prototype.getSelectedId = function(){
        return this.getAncestorOfType("ux.cdb.admin.system.department.Department").getSelectedId();
    };
    block.prototype.doValidate = function() {
        var departmentObject = this.getDescendantOfName("blk_departmentInfoProvider").getData();
        alert(departmentObject);
    }
    block.prototype.onCodeChanged = function(objTxt, objEVENT, strPREVIOUS, strVALUE){
        this.doValidate();
    };
    block.prototype.onNameChanged = function(objTxt, objEVENT, strPREVIOUS, strVALUE){
        this.doValidate();
    };
    block.prototype.onTypeChanged = function(objSel, objEVENT, strRECORDID) {
        this.doValidate();
    };
    block.prototype.onLevelChanged = function(objSel, objEVENT, strRECORDID) {
        this.doValidate();
    };
    block.prototype.onStatusChanged = function(objSel, objEVENT, strRECORDID) {
        this.doValidate();
    };
    block.prototype.onModeChanged = function(objSel, objEVENT, strRECORDID) {
        this.doValidate();
    };
    block.prototype.initialize = function(msg){
      //this.wizard = this.getAncestorOfType("ux.megatron.gui.SteppedWizard");
    };
    
    block.prototype.onCancel = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL){
      this.doClose();
      return null; // return "NONE" to not advance panels
    };
    
    block.prototype.onCustomNav = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL){
      return null; // return "NONE" to not advance panels
    };
    block.prototype.doClose = function(){
      this.getAncestorOfType("ux.cdb.admin.system.department.departmentWizard.DepartmentWizard").doClose();
    };
    
    block.prototype.onFinish = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL){
        //this.doValidate();
        try{
            var departmentData = this.getDescendantOfName("blk_departmentInfoProvider").getData();
            var departmentRecord = departmentData.getFirstChild();
            var mtx = this.getMatrix();
            if(this.mode != "edit"){
                departmentRecord.setAttribute("jsxtext", departmentRecord.getAttribute("Org_Name"));
                departmentRecord.setAttribute("jsxid", departmentRecord.getAttribute("Internal_Org_Id"));
                var selectedId = this.getSelectedId() ? this.getSelectedId() : "jsxroot";
                mtx.insertRecordNode(departmentRecord, selectedId);
                mtx.insertRecordProperty(selectedId, "jsxopen", 1, false);
            } else {
                var jsxid = this.jsxid;
                mtx.insertRecordProperty(jsxid, "Internal_Org_Code", departmentRecord.getAttribute("Internal_Org_Code"), false);
                mtx.insertRecordProperty(jsxid, "Org_Name", departmentRecord.getAttribute("Org_Name"), false);
                mtx.insertRecordProperty(jsxid, "Org_Type_Code", departmentRecord.getAttribute("Org_Type_Code"), false);
                mtx.insertRecordProperty(jsxid, "Org_Level_Code", departmentRecord.getAttribute("Org_Level_Code"), false);
                mtx.insertRecordProperty(jsxid, "Internal_Org_Status_Code", departmentRecord.getAttribute("Internal_Org_Status_Code"), false);
                mtx.insertRecordProperty(jsxid, "Branch_Approve_Mode_Code", departmentRecord.getAttribute("Branch_Approve_Mode_Code"), false);
                this.getAncestorOfType("ux.cdb.admin.system.department.Department").onDepartmentSelected(mtx, null, this.jsxid);
            }
            mtx.repaintData();
        } catch(ex) {
            alert(ex.message);
        }
        this.doClose();
        return null;
    };

    block.prototype.onBeforeShow = function(objWIZARD, objBUTTON, objEVENT, strLASTPANEL){
      if (!this.getChild(0)) {
        var me = this;
        ux.megatron.Main.loadUIResourceAsync(me, "ux.cdb.admin", "ux/cdb/admin/system/department/departmentWizard/step1/ui/DepartmentInfoContent.xml", me, me.initialize);
      }
      return null; // return "NONE" to not advance panels
    };
    
    block.prototype.onAfterHide = function(objWIZARD, objBUTTON, objEVENT, strNEXTPANEL){
      return null; // return "NONE" to not advance panels
    };
  });
}
